#include <iostream>
#include "index_manager.h"
#include "config.h"
#include "uvlog.h"
using namespace std;
void usage(int argc,char** argv);

int main(int argc,char** argv)
{
	usage(argc,argv);

	const char *cfgfile = argv[1];
	if(access(cfgfile,F_OK))
	{
		cout << "config file not reachable!" << endl;
		exit(1);
	}

	CConfig * cfg = CConfig::getInstance();
	if(cfg->ParseConfig(cfgfile) != 0){
		cerr << "parse config failed";
		return -1;
	}
	
	INIT_LOG("/dev/null",1024*1024,5);
	g_pLog->setLogLevel(0);

	IndexManager *obj = IndexManager::instance(cfg->GetStrVal("BTREE", "path"), cfg->GetStrVal("BTREE", "prefix"), cfg->GetStrVal("BTREE", "key"));
	if(obj == NULL)
	{
		LOG_ERROR("Instance IndexManager failed,Please chech conf");
		exit(-1);
	}

	obj->setMaxMemory(1024*1024*cfg->GetIntVal("BTREE", "maxmem", 1024));

	obj->dump();
	
	return 0;
}

void usage(int argc,char** argv)
{
	if(argc < 2 )
	{
		cout << "usage:" << endl
				<< argv[0] << " conf" << endl;
		
		exit(1);
	}
}



